package com.crayfish.quduo.presenter;

import android.content.Context;

import com.crayfish.quduo.base.RxPresenter;
import com.crayfish.quduo.http.RetrofitHelper;
import com.crayfish.quduo.model.UserBean;
import com.crayfish.quduo.presenter.contract.MeContract;
import com.crayfish.quduo.utils.SharedPreferencesUtil;
import cn.bmob.v3.BmobUser;

/**
 * Created by crayfish on 2016/12/29.
 */
public class MePresenter extends RxPresenter<MeContract.View> implements MeContract.Presenter {

    private RetrofitHelper mRetrofitHelper;

    public MePresenter(RetrofitHelper retrofitHelper){
        this.mRetrofitHelper = retrofitHelper;
    }

    @Override
    public void getUserBean(Context context) {
        UserBean user = BmobUser.getCurrentUser(UserBean.class);
        if(user != null){
            mView.showUser(user);
        }else{
            SharedPreferencesUtil.clearUser(context);
            mView.gotoLogin();
        }
    }
}
